import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

from comm.base_keyword import BaseKeyword


def open():
    # 取消"Chrome正受到自动软件的控制"
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_experimental_option('useAutomationExtension', False)
    chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
    # 禁用自动刷新
    #chrome_options.add_argument("--disable-prompt-on-repost")
    driver = webdriver.Chrome(
        service=Service(executable_path=r"D:\PyProjects\chromedriver-win64\chromedriver.exe"),
        options=chrome_options)
    # 窗口最大化
    driver.maximize_window()
    # 禁用JavaScript执行
    #driver.execute_script("window.javascriptEnabled = false;")
    return driver


if __name__ == '__main__':
    driver=open()
    keywords = BaseKeyword(driver)
    keywords.login()
    keywords.query()

    keywords.sel_li_elements()
    time.sleep(20)